package m4d2;

import java.util.Arrays;
import java.util.Comparator;

//函数式接口作为返回值类型
public class dComparator {
    public static Comparator<String> method1() {
        return new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return o2.length()-o1.length();
            }
        };
    }

    public static Comparator<String> method2(){
        return (String o1,String o2)->{
            return o2.length()-o1.length();
        };
    }



    public static void main(String[] args) {
        String[] strs = {"aaa","bbbb","ccccccc"};

        Arrays.sort(strs,method2());
        System.out.println(Arrays.toString(strs));
    }
}
